package bobaini.com.hunger;

import lombok.extern.slf4j.Slf4j;

/**
 * @author: liuyi
 * ClassName: Test
 * Version: 1.0.0
 * DateTime: 2021/03/31-10:36:00
 * Description:
 * 1:构造函数私有化, 阻止别人new对象, 不能创建实例
 * 2:共享一个对象, 用static修饰：static修饰的都是类变量, 类方法, 除此之外都是实例对象, 实例方法
 */
@Slf4j
public class HungerSingleModel {
    private static HungerSingleModel lazySingleModel = new HungerSingleModel();

    private HungerSingleModel() {

    }

    public static HungerSingleModel getLazySingleModel() {
        log.info("恶汉模式开始了..");
        return lazySingleModel;
    }
}


class HungerSingleModelTest {
    public static void main(String[] args) {
        HungerSingleModel lazySingleModel = HungerSingleModel.getLazySingleModel();
    }
}
